using System;
using System.Data.Linq;
using Close2Poco;
using Close2Poco.Tests.TestEntities;

namespace Close2Poco.Tests.TestEntities
{
    public class Order : IClose2PocoEntity
    {
        EntityRef<Customer> _customer;

        [IsDbGenerated]
        public int OrderID { get; set; }

        public DateTime OrderDate { get; set; }

        [DbType("NChar(5)")]
        public string CustomerID { get; private set; }     // linq needs this. We don't have the code gen to make the setter safe, so we restrict access to it. (The entityRef is not enough since, it doesn't (necessarily) store the keys. INstead, it reads them from here.  Only linq needs it. So it is not public or anything) 
        // yes it is a pain but (a) it lets us control mappings for it and (b) in the rare cases where DB joins must be done (rather than dotted notation) it gives us an ID to use in the joins in linq qeuries)

        public Customer Customer
        {
            get { return _customer.Entity;  }
            set { this.SetValue(ref _customer, value); }
        }
    }
}